<?php
class mysqlclass
{

	var $user, $pass, $host, $sql, $db, $tab;
	function mysqlclass()
	{
	}
	
	function connect($_host, $_user, $_pass, $_db)
	{
		$this->user = $_user;
		$this->pass = $_pass;
		$this->host = $_host;
		$this->db = $_db;
		$this->sql = @mysql_connect($_host,$_user,$_pass ) or die ("Blad polaczenia: ". mysql_error());
		if ($this->sql)
		{
			
			$this->db =  @mysql_select_db($_db) or die ("Nie ma takiej bazy danych: ". mysql_error());
		}                
	}
	
	function set($_ile)
	{
		if ($this->db)
			@mysql_query("UPDATE `licznik` SET `ile` = ".$_ile." WHERE `licz` ='a' LIMIT 1 ;");
	}

	function getstatus($id)
	{
		if ($this->db)
		{
			$result = mysql_query("SELECT url FROM `urls` WHERE `id` = '".$id."'");
			$row = mysql_fetch_array( $result );
			return $row['url'];
		}	
	}	
	
	function insert($url)
	{
		if ($this->db)
		{
			$result = mysql_query("INSERT INTO `urls` (`id` ,`url`)
			                        VALUES (NULL , '".$url."');");
			return $result;
		}	
	}		

	function disconnect()
	{
		@mysql_close($this->sql);	
	}
}

?>